﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLNHBUS;
using QLNHDAO;


namespace PMQLNhaHang
{
    public partial class fmLogin : Form
    {
        public static NhanVien NhanVienInstance;
        public fmLogin()
        {
            InitializeComponent();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            NhanVienInstance = KiemTraThongTinDangNhap();
            if (NhanVienInstance != null)
            {
                FMain fmMain = new FMain();
                fmMain.Show();
                this.Hide();
            }
            else
            {
                lbError.Text = "Đăng Nhập Không Thành Công";
            }
        }

        private NhanVien KiemTraThongTinDangNhap()
        {
            return NhanVienBUS.LayNhanVienTheoTenVaMatKhau(tbDangNhap.Text, tbMatKhau.Text);
        }

        private void btnHuyBo_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void fmLogin_Load(object sender, EventArgs e)
        {

        }

        private void fmLogin_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}
